<?php
/* @var $this SiteController */
//
//$this->pageTitle=Yii::app()->name . ' - About';
//$this->breadcrumbs=array(
//	'About',
//);
?>


<div id="excel-wrapper" class="container">
    <div class="row">
        <div class="col-md-12">
            <div class="panel panel-primary">
                <div class="panel-heading">项目排期</div>
                <div class="panel-body">
                    <div id="excel-container">

                    </div>
                </div>
            </div>

        </div>

    </div>
</div>
<script>
    $(function() {

        buildExcel();
        var sheetContent  //数据内容
                , $container = $("#excel-container")
                , handsontable = $container.data('handsontable');
        //        , blankContent = handsontable.getData();
        
                loadContent();


                        //加载表格内容
                                function loadContent() {
                                    $.ajax({
                                        type: "post",
                                        url: "/testdrive/index.php/schedule/schedulelist",
                                        data: "",
                                        success: function(str) {
                                           alert(str);
                                            var object = JSON.parse(str);

                                            handsontable.loadData(object);

                                        },
                                        error: function() {
                                            alert("不能获得值");
                                        }
                                    }
                                    );
                                }
                    });


            function buildExcel() {
                var data = [
                    {dateline: "", one: "", two: "", three: "", four: "", five: ""}
                ];
                var $tmpExcel = $('#excel-container');
                $tmpExcel.handsontable({
                    data: data,
                    minSpareRows: 1,
                    colHeaders: ["日期", "任务一", "任务二", "任务三", "任务四", "任务五"],
                    //      contextMenu: true,
                    columnSorting: true,
                    columns: [
                        {
                            data: "dateline",
                            //type: "checkbox",
//                    checkedTemplate: "true",
//                    uncheckedTemplate: ""
                        },
                        {
                            data: "one"
                        },
                        {
                            data: "two"
                        },
                        {
                            data: "three"
                        },
                        {
                            data: "four"
                        },
                        {
                            data: "five",
//                    type: 'autocomplete',
//                    source: ["毛鹏宇", "刘鑫", "赵峰", "马胜盼", "翟飞宇", "于涛", "寇德键", "刘畅", "李志辉", "孙浩", "王晓远"],
//                    strict: false
                        }
                        //,
//                {
//                    data: "deadline",
//                    type: 'date',
//                    dateFormat: 'yy-mm-dd'
//                }
                    ]
                    ,
//            cells: function(row, col, prop) {
//                var cellProperties = {};
//                if ($tmpExcel.handsontable('getData')[row][prop] !== '') {
//                   // cellProperties.readOnly = true;
//                }
//                return cellProperties;
//            }


                });
            }
</script>
